home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-09-11 | 2.1 KB | 70 lines | [TEXT/CWIE] |
- // IACharStream.h
- // Copyright: © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
-
- #pragma once
- #ifndef IACharStream_h
- #define IACharStream_h
- #pragma import on
-
- #include "IACommon.h"
-
- #pragma IA_BEGIN_EXPORTS
-
- class IACharStream : public IAObject {
- public:
- IACharStream();
- virtual ~IACharStream();
- // common operations are handled inline by base class
-
- // note: eos is assumed to be false, and is only set when eos is reached
- // also, when eos is set, the return value should be ignored
- char GetNextChar(bool* eos) {
- return nextChar < endChar ? *(nextChar++) : ReadPastEndOfBuffer(eos);
- }
-
- inline uint32 CurrentPos() { return bufferPos + (nextChar - buffer); }
-
- void GetTextSpan(char* buffer, uint32 startPos, uint32 endPos);
-
- // subclasses may wish to implement a faster version of this
- virtual void AdvanceTo(uint32 pos);
-
- // accessors needed for string-based subclasses
- char* GetBuffer() const { return buffer; } // returns current buffer
- void SetBuffer(char* newValue) { buffer = newValue; } // sets current buffer
-
- char* GetNextCharInBuffer() const { return nextChar; }
- void SetNextCharInBuffer(char* newValue) { nextChar = newValue; }
-
- char* GetEndChar() const { return endChar; }
- void SetEndChar(char* newValue) { endChar = newValue; }
-
- uint32 GetBufferPos() const { return bufferPos; }
- void SetBufferPos(uint32 newValue) { bufferPos = newValue; }
-
- protected:
- // subclasses must implement only this one method
- virtual uint32 GetNextBuffer(char* buffer, uint32 bufferLen) = 0;
-
- private:
- char ReadPastEndOfBuffer(bool *eos);
- char* lastBuffer; // the previous buffer
- char* lastEndChar; // the end of the previous buffer
-
- IACharStream(IACharStream&);// don't define a copy constructor
-
- char* buffer; // the current buffer
- char* nextChar; // pointer to the next character to read in buffer
- char* endChar; // pointer to the end of the current buffer
- uint32 bufferPos; // position of the first char in buffer
-
- };
-
- IAExceptionCode TextSpanUnavailable = 'VTSU';
-
- #pragma IA_END_EXPORTS
-
- #pragma import reset
-
- #endif
-